#include <stdio.h>

#define MAX_LENGTH 22

#define get_int(n) scanf("%d ", &n);
#define get_ints(n1,n2) scanf("%d %d ", &n1, &n2);


int main ()
{
	int data_sets, n, r, i;
	char s[MAX_LENGTH], *c;

	get_int(data_sets);
	do
	{
		get_ints (n, r);
		fgets(s, MAX_LENGTH, stdin);

		printf("%d ", n);
		for (c = s; isprint(*c); ++c)
		{
			for (i = 0; i < r; ++i)
				putchar(*c);
		}
		putchar('\n');
	}
	while (n < data_sets);

	return 0;
}